class FollowMouse extends egret.DisplayObjectContainer {
    private arrow:Arrow
    private speed:number = 5

    public constructor() {
        super()
        this.once( egret.Event.ADDED_TO_STAGE, this.onAddToStage, this)
    }

    private onAddToStage(event:egret.Event) {
        this.arrow = new Arrow()
        this.arrow.x = this.stage.stageWidth / 2
        this.arrow.y = this.stage.stageHeight / 2
        this.addChild(this.arrow)

        this.stage.addEventListener( egret.TouchEvent.TOUCH_MOVE, ( evt:egret.TouchEvent )=>{
            let dx : number = evt.localX - this.arrow.x,
                dy : number = evt.localY - this.arrow.y,
                angle : number = Math.atan2(dy, dx),
                vx : number = Math.cos(angle) * this.speed,
                vy : number = Math.sin(angle) * this.speed
            
            this.arrow.rotation = angle * 180 / Math.PI
            this.arrow.x += vx
            this.arrow.y += vy
        }, this )

        this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this)
    }

    private onEnterFrame(event:egret.Event) {
        
    }
}